<{include file="public/header" /}>

<style>
  .layui-table tbody tr:hover {
      background-color: transparent;
  }
  .layui-table-cell{
    height:auto;
    /*line-height:50;*/
    text-overflow: inherit;
    white-space: normal;
  }
</style>
<body>
        
<!-- <blockquote class="layui-elem-quote layui-text" style="margin-bottom: 0px;background-color: white">
  说明：请认真填写，不能修改！
</blockquote> -->

<!-- 选项卡开始 -->
<div class="layui-tab layui-tab-card" style="margin-top: -1px;">
  <ul class="layui-tab-title">
    <li class="layui-this">填空</li>
  </ul>
  <div class="layui-tab-content">
    <!-- 单选题选项卡1 -->
    <div class="layui-tab-item layui-show">
      <form class="layui-form" >
        <div class="layui-form-item">
          <textarea id="tiankong" name="tiankong" placeholder="填空题干"  lay-verify="tiankong" class="layui-textarea" ><{$qdata.qtitle}></textarea>
        </div >
        <div class="layui-form-item">
          <div class="layui-input-block" style="margin-left: 0px;">
            <input type="text" name="right" required  lay-verify="required" placeholder="答案（如无可填写略）" autocomplete="off" class="layui-input" value="<{$qdata.rightselect}>">
          </div>
        </div>
        <div class="layui-form-item">
                <input type="hidden" name="qid" id="type" value="<{$qdata['qid']}>">
          </div>
        <div class="layui-form-item">
          <div class="layui-input-block">
            <button class="layui-btn" lay-submit id="tiankongsub" lay-filter="tiankongsub" type = "button">立即提交</button>
          </div>
        </div>
      </form>
    </div>
    <!-- 单多选题选项卡结束1 -->
  </div>
</div>
<!-- 选项卡结束 -->
<!-- 配置文件 -->
 
<script>

layui.use(['form','element','layer','jquery','layedit'], function(){
  var $ = layui.$,element = layui.element,form = layui.form,layer = layui.layer,layedit = layui.layedit;
  //----------上面引入layui下面开始业务，分割一下-----------------//
  //初始化富文本
  layedit.set({
    uploadImage: {
      url: "<{:url('upload/upimg')}>" //接口url
      ,type: '' //默认post
    }
  });
  var edittiankong=layedit.build('tiankong',{
    tool: ['image','underline'],height:80
  });
  //layedit.setContent(editquestion, "<{$qdata['qtitle']}>|htmlspecialchars_decode");

  //提交表单的时候同步内容到 textarea
  form.verify({ 
            tiankong: function(value) { return layedit.sync(edittiankong); }
  });
  // //选择单选多选时的提示
  // form.on('radio(selecttype)', function(data){
  //   //console.log(data.elem); //得到radio原始DOM对象
  //   console.log(data.value); //被点击的radio的value值
  //   if (data.value==1) {
  //      layer.tips('单选题，只有一个正确答案！', data.othis,{tips: 1})
  //   } else {
  //       layer.tips('多选题，可以有多个正确答案！', data.othis);
  //   }
    
  // });  
  
    
   //监听表单提交
  form.on('submit(tiankongsub)', function(data){
      //console.log(data.field);

     // layer.alert(JSON.stringify(data.field), {
     //    title: '最终的提交信息'
     //  });
     
    //alert(layedit.getContent(editquestion));
        layer.confirm('确定提交?', {btn: ['提交','取消'],btnAlign: 'c', title:'请确认'}
        ,function(index){
          //do something
            $.post("<{:url('tiankong_edit')}>",data.field,function(data,status){
              //alert(data);
              //alert(JSON.stringify(data));
             // console.log(data);
              if(data===1){
                //layer.close(index);
                layer.msg('提交成功!',function(){
                  x_father_close();
                   parent.location.reload();
                }); 
              }else{
                  layer.alert(data);
              }
                
              
           })
          
        });  
   });
  


})
</script>

</body>
</html>